package com.bawei.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.bawei.database.entity.UserInfoEntity

/**
 * Author: Jason Zhang
 * Date: 2025/4/25
 * Desc: 用户信息操作类
 *
 * ORM类型数据库（对象关系数据库），增删改查都是操作对象（Room和GreenDao）
 * SQLite数据，增删改查操作的SQL语句
 */

@Dao
interface UserInfoDao {

    @Insert
    suspend fun insertUserInfo(vararg userInfo: UserInfoEntity) //vararg关键字代表可以批量操作(一条或多条数据)

    @Delete
    suspend fun deleteUserInfo(vararg userInfo: UserInfoEntity)

    @Update
    suspend fun updateUserInfo(vararg userInfo: UserInfoEntity)

    @Query("select * from user_info order by id")
    suspend fun queryAllUserInfo(): List<UserInfoEntity>

    @Query("select * from user_info where id = :userId")
    suspend fun queryUserInfoById(userId: Int): UserInfoEntity

}